import { FC } from 'react';
import classNames from 'classnames';
import { Row } from 'antd';
import styles from './index.less';

import { DescriptionListProps } from './interface';

const DescriptionList: FC<DescriptionListProps> = ({
  className,
  title,
  layout,
  gutter,
  children,
  size,
  ...rowProps
}) => {
  const clsString = classNames(styles.descriptionList, styles[layout || 'horizontal'], className, {
    [styles.small]: size === 'small',
    [styles.large]: size === 'large',
  });
  return (
    <div className={clsString}>
      {title ? <div className={styles.title}>{title}</div> : null}
      <Row gutter={gutter} {...rowProps}>
        {children}
      </Row>
    </div>
  );
};

DescriptionList.defaultProps = {
  layout: 'horizontal',
  gutter: [32 ,10],
};

export default DescriptionList;
